<?php
/**
 *  This class inhabits the functionality to prepare 
 *  and send the mail
 * 
 *  @author mario
 *  @package Mailgun
 *  @license http://www.gnu.org/licenses/lgpl.html LGPL
 */
class Mailgun_Mail {

    /**
     *  mail properties
     */
    private $html = string;
    private $text = string;
    private $crlf = string;
    private $recipient = string;

    # set headers
    private $headers = array('From'    => 'mailgun@h4k.in',
                             'Subject' => 'mailgun test message - \'">>1%0A%002',
                             'Content-Type' => 'text/html; charset=utf-8'
                             );

 
    /**
     *  constructor
     */
    public function __construct($html, $text, $crlf) {
        
        $this->prepareMail();
        $this->sendMail();
        
        return true;
    }       
    
    /**
     *  this method prepared the data needed for PEAR Mail
     */
    private function prepareMail() {

        $mime = new Mail_mime($this->crlf);
        $mime->setTXTBody($this->text);
        $mime->setHTMLBody($this->html);
        $body = $mime->get();
        $hdrs = $mime->headers($this->headers);
        
        return true;
    }
   
    /**
     *  this method plainly sends out the mail
     */   
    private function sendMail() {

        $mail =& Mail::factory('mail');
        $mail->send($this->recipient, $this->headers, $this->html);
        
        return true;
    }
   
}